<?php

namespace App\Http\Controllers\home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;

class Detail extends Common
{
    //文章详情页
    public function index(Request $request)
    {
        $aid = (int)$request->id;
        $data['item'] = DB::table('article')->where('id',$aid)->item();
        $data['detail'] = DB::table('article_detail')->where('aid',$aid)->item();
        DB::table('article')->where('id',$aid)->update(array('pv'=>($data['item']['pv']+1)));
        $data['re'] = DB::table('article')->orderBy('pv','desc')->lists();
        $data['admin']   = DB::table('admin')->cates('id');
        $data['user']   = DB::table('member')->cates('id');
        $data['member'] = Auth::guard('member')->user();
        $data['url'] = $request->url();
        return view('home.detail',$data);
    }
}
